package WorkComparator;

import WorkComparator.CalculateTotalprice;
import WorkComparator.Method;
import WorkComparator.Supermarket;

import java.util.*;

import static java.lang.Math.max;

public class TestSupermarket {
    public static void main(String[] args) {
        Supermarket c1 = new Supermarket(12,22,13);
        Supermarket c2 = new Supermarket(8,28,17);
        Supermarket c3 = new Supermarket(22,33,2);


//        CalculateTotalprice c = max(c1,c2,new Method());
//
//        System.out.println(c.getTotal());

        List<Supermarket> calculateTotalpriceList=new ArrayList<>();
        calculateTotalpriceList.add(c1);
        calculateTotalpriceList.add(c2);
        calculateTotalpriceList.add(c3);

        Collections.sort(calculateTotalpriceList,new Method());
        for (Supermarket item:calculateTotalpriceList){
            System.out.println(item.getTotal());
        }
        System.out.println();
        Collections.reverse(calculateTotalpriceList);
        for (Supermarket item:calculateTotalpriceList){
            System.out.println(item.getTotal());
        }
        System.out.println();

        for (Supermarket item:calculateTotalpriceList){
            System.out.println(item.getTotal());
        }
        System.out.println();
        System.out.println(Collections.max(calculateTotalpriceList,new Method()).getTotal());
    }

    private static CalculateTotalprice max(CalculateTotalprice c1, CalculateTotalprice c2, Comparator<CalculateTotalprice> g) {
        if (g.compare(c1,c2)>0)
            return c1;
        else
            return c2;
    }
}
